package com.huqu.daoimpl;

import java.sql.Types;
import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import com.huqu.basedao.QbDaoSupport;
import com.huqu.basedao.QbEntityMapper;
import com.huqu.basedao.QbSqlParam;
import com.huqu.dao.N300Dao;
import com.huqu.entities.N300;
import com.huqu.utils.ApplicationConstant;
import com.huqu.utils.SqlNames;

@Repository(value = ApplicationConstant.REPOSITORY_NAME_N300)
@Scope("prototype")
public class N300DaoImpl extends QbDaoSupport implements N300Dao {

	@Override
	public List<N300> ListOfTabN300(int nIDMUC, int nIDTHELOAI, int nOFFSET,
			int nLIMIT, int nGETNUMROW, int nSORT, int nORDERBY, String vLANG) {
		List<QbSqlParam> listParams = new ArrayList<QbSqlParam>();
		listParams.add(new QbSqlParam(Types.INTEGER, nIDMUC));
		listParams.add(new QbSqlParam(Types.INTEGER, nIDTHELOAI));
		listParams.add(new QbSqlParam(Types.INTEGER, nOFFSET));
		listParams.add(new QbSqlParam(Types.INTEGER, nLIMIT));
		listParams.add(new QbSqlParam(Types.INTEGER, nGETNUMROW));
		listParams.add(new QbSqlParam(Types.INTEGER, nSORT));
		listParams.add(new QbSqlParam(Types.INTEGER, nORDERBY));
		listParams.add(new QbSqlParam(Types.CHAR, vLANG));
		setQueenBListSqlParams(listParams);
		// set sql name
		setQueenBSqlName(SqlNames.LISTOFTABN300);
		// set row mapper
		setQueenBEntityMapper(new QbEntityMapper(N300.class));
		executeQueenBQuery();
		List<N300> listN300 = (List<N300>) getListReturn();
		return listN300;
	}

	@Override
	public List<N300> ListOfTabN300INFO(String vMD5BAIVIET, String vLang) {
		List<QbSqlParam> listParams = new ArrayList<QbSqlParam>();
		listParams.add(new QbSqlParam(Types.CHAR, vMD5BAIVIET));
		listParams.add(new QbSqlParam(Types.CHAR, vLang));
		setQueenBListSqlParams(listParams);
		// set sql name
		setQueenBSqlName(SqlNames.LISTOFTABN300INFO);
		// set row mapper
		setQueenBEntityMapper(new QbEntityMapper(N300.class));
		executeQueenBQuery();
		List<N300> listN300 = (List<N300>) getListReturn();
		return listN300;
	}

	@Override
	public int InsertTabN300(int nIDBAIVIET, int nIDTHELOAI, String vTIEUDE_VI,
			String vTIEUDE_EN, String vTOMTAT_VI, String vTOMTAT_EN,
			String vNOIDUNG_VI, String vNOIDUNG_EN, String vHINHANH,
			int nNGUOITAO, int nDAXOA, int nKIEMDUYET, int nUUTIEN) {
		
		List<QbSqlParam> listParams = new ArrayList<QbSqlParam>();
		listParams.add(new QbSqlParam(Types.INTEGER, nIDBAIVIET));
		listParams.add(new QbSqlParam(Types.INTEGER, nIDTHELOAI));
		listParams.add(new QbSqlParam(Types.CHAR, vTIEUDE_VI));
		listParams.add(new QbSqlParam(Types.CHAR, vTIEUDE_EN));
		listParams.add(new QbSqlParam(Types.CHAR, vTOMTAT_VI));
		listParams.add(new QbSqlParam(Types.CHAR, vTOMTAT_EN));
		listParams.add(new QbSqlParam(Types.CHAR, vNOIDUNG_VI));
		listParams.add(new QbSqlParam(Types.CHAR, vNOIDUNG_EN));
		listParams.add(new QbSqlParam(Types.CHAR, vHINHANH));
		listParams.add(new QbSqlParam(Types.INTEGER, nNGUOITAO));
		listParams.add(new QbSqlParam(Types.INTEGER, nDAXOA));
		listParams.add(new QbSqlParam(Types.INTEGER, nKIEMDUYET));
		listParams.add(new QbSqlParam(Types.INTEGER, nUUTIEN));
		setQueenBListSqlParams(listParams);
		// set fuction
		setQbFunction(true);
		setQbFunctionReturnType(Types.INTEGER);
		setQueenBSqlName(SqlNames.INSERTTABN300);
		executeQueenBQuery();
		int re = Integer.parseInt(getObjectReturnFunction().toString());
		return re;
	}

}
